<template>
  <el-card class="glass-card" shadow="hover">
    <template #header>
      <div class="card-header">
        <span>状态栏</span>
        <el-tag size="small" effect="plain">{{ items.length }} 条</el-tag>
      </div>
    </template>
    <div class="list">
      <transition-group name="fade-move" tag="div">
        <el-scrollbar v-if="items.length > 0">
          <div class="row" v-for="it in items" :key="it.index + '_' + it.time">
            <div class="time">{{ it.time }}</div>
            <div class="name">{{ it.name }}</div>
          </div>
        </el-scrollbar>
      </transition-group>
    </div>
  </el-card>
</template>

<script setup lang="ts">
import type { StatusBarItem } from "@/api/hmi/home.api";

defineOptions({ name: "StatusBarCard" });
defineProps<{ items: StatusBarItem[] }>();
</script>

<style scoped lang="scss">
.glass-card {
  background: rgba(255, 255, 255, 0.6);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.6);
  border-radius: 16px;
}
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-weight: 600;
}
.list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 220px;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin; /* Firefox */
  scrollbar-color: #94a3b8 transparent; /* Firefox */
}
/* 滚动条美化（WebKit） */
.list::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
.list::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, #cbd5e1 0%, #94a3b8 100%);
  border-radius: 8px;
}
.list::-webkit-scrollbar-track {
  background: transparent;
}
.row {
  display: grid;
  grid-template-columns: 1fr 1.3fr;
  gap: 12px;
  padding: 8px 10px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.55);
  border: 1px solid rgba(255, 255, 255, 0.7);
}
.time {
  color: #64748b;
  font-family:
    ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New",
    monospace;
  font-size: 12px;
}
.name {
  color: #111827;
  font-size: 13px;
}

.fade-move-enter-active,
.fade-move-leave-active {
  transition: all 0.3s ease;
}
.fade-move-enter-from,
.fade-move-leave-to {
  opacity: 0;
  transform: translateY(-8px);
}
</style>
